#ifndef _LJMU_GAMETIMER_H_
#define _LJMU_GAMETIMER_H_

/***************************************
*
*
*
*
***************************************/
class LJMUUtilGameTimer
{
public:
	//------------CONSTRUCTORS/DESTRUCTORS--------------------------------------------
	LJMUUtilGameTimer();			//Constructor for the Game Timer

	//------------GETTERS AND SETTERS-------------------------------------------------
	float getTimeInSeconds();  //Get the Total Elapsed Time in Seconds
	float getTimePerFrame();   //Get the Current Time Per Frame in Seconds

	//------------PUBLIC METHODS------------------------------------------------------
	void resetTimer();				//Reset the Timer
	void startTimer();				//Start the Timer
	void stopTimer();				//Stop the Timer (Pause)
	void updateTimer();				//Update the Timer Values, should be called once per frame

private:
	//------------CLASS MEMBERS--------------------------------------------------------
	double _prop_resolution;
	double _frame_delta;			//Stores the difference in time between the two most recent
	bool   _state_is_stopped;		//Stores Whether the time has been stopped or not. 
	
	__int64 _time_base;				//The Actual Time of the System Clock
	__int64 _time_stopped;			//The Time Elapsed when the call to stopTimer was made		
	__int64 _time_elapsed_prev;		//The Time Elapsed since the previous call to updateTimer()
	__int64 _time_elapsed_pause;	//The Amount of Time that Elapsed between stopTimer followed by startTimer()
	__int64 _time_elapsed_curr;		//The Time Elapsed after the the most recent call to updateTimer() 
};

//--------------INLINE GETTERS AND SETTERS----------------------------------------------

/***********************************
*
***********************************/
inline float LJMUUtilGameTimer::getTimeInSeconds()
{
	if(this->_state_is_stopped)
		return (float)((this->_time_elapsed_curr - this->_time_base) * this->_prop_resolution);
	else
		return (float)(((this->_time_elapsed_curr - this->_time_elapsed_pause) - this->_time_base) * this->_prop_resolution);
}

/***********************************
*
***********************************/
inline float LJMUUtilGameTimer::getTimePerFrame()
{
	return (float)this->_frame_delta;
}

#endif